home *** CD-ROM | disk | FTP | other *** search
/ MacWorld Ultimate Mac / Macworld Ultimate Mac CD-ROM (1994)(IDG).iso / The Best of BMUG / Utilities / Control Panels and Extensions / ClipboardMagician.76 / iconpict.p < prev    next >
Text File  |  1990-12-11  |  2KB  |  64 lines

  1. unit UConvertor;
  2. interface
  3.     const
  4. {the constants are for use of the simulator only }
  5.         testID = 128; { change to reflect code resource ID }
  6.         testType = 'ICON'; { change to reflect the data type you are testing }
  7.     type
  8.         routineInfo = record
  9.                 entryPoint: ProcPtr;
  10.                 resID: Integer;
  11.                 parmCount: Integer;
  12.                 useDefault: boolean;
  13.             end;
  14.         routineInfoPtr = ^routineInfo;
  15.         parmInfo = record
  16.                 srcType: ResType;
  17.                 srcHandle: Handle;
  18.                 dstType: ResType;
  19.                 dstHandle: Handle;
  20.             end;
  21.         parmInfoPtr = ^parmInfo;
  22.  
  23. { the name xMain is for debugging use only, change to Main before making the code resource }
  24.  
  25.     function xMain (myInfoPtr: routineInfoPtr; parmPtr: parmInfoPtr): OSErr;
  26. implementation
  27.  
  28.     function CallExt (rtnRsrc: ResType; NamePtr: Str255; parmCount: integer; useDefault: Boolean; parmPtr: Ptr; theAddr: Ptr): OSErr;
  29.     inline
  30.         $205F, $4e90; { move.l (A7)+, A0;  jsr (A0)}
  31.  
  32.     function xMain (myInfoPtr: routineInfoPtr; parmPtr: parmInfoPtr): OSErr;
  33.         var
  34.             r: rect;
  35.             aBitMap: BitMap;
  36.             orgPort: GrafPtr;
  37.             tempPort: GrafPort;
  38.             err: OSErr;
  39.     begin
  40.         HLock(parmPtr^.srcHandle);
  41.         GetPort(orgPort);
  42.         OpenPort(@tempPort);
  43.         SetRect(r, 0, 0, 32, 32);
  44.         ClipRect(r);
  45.         with aBitMap do
  46.             begin
  47.                 baseAddr := parmPtr^.srcHandle^;
  48.                 rowBytes := 4;
  49.                 bounds := r;
  50.             end;
  51.         parmPtr^.dstHandle := Handle(OpenPicture(r));
  52.         if parmPtr^.dstHandle <> nil then
  53.             begin
  54.                 parmPtr^.dstType := 'PICT';
  55.                 CopyBits(aBitMap, tempPort.portBits, aBitMap.bounds, r, srcCopy, nil);
  56.                 ClosePicture;
  57.             end;
  58.         ClosePort(@tempPort);
  59.         SetPort(orgPort);
  60.         HUnLock(parmPtr^.srcHandle);
  61.         xMain := NoErr;
  62.     end;
  63.  
  64. end.